package dca.sistemascontrole.view.grafico;

import dca.sistemascontrole.dao.GraphicDataManager;
import dca.sistemascontrole.view.PanelOpcoesGrafico;
import java.awt.Frame;

/**
 *
 * @author Rafael
 */
public class OfflineChartsDialog extends javax.swing.JDialog {

    private GraphicDataManager dataManager;
    private PanelOpcoesGrafico pnlOpcaoGraficos;

    public OfflineChartsDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();

        pnlGraficoNivel.setMaximunVisiblePeriod(1000 * 60 * 5);
        pnlGraficoTensao.setMaximunVisiblePeriod(1000 * 60 * 5);

        pnlOpcaoGraficos = new PanelOpcoesGrafico(pnlGraficoNivel, pnlGraficoTensao, null);
        pnlOpcaoGraficosHolder.add(pnlOpcaoGraficos);
    }

    public OfflineChartsDialog(GraphicDataManager dataManager, Frame owner, boolean modal) {
        this(owner, modal);
        this.dataManager = dataManager;


        pnlGraficoNivel.setValues(dataManager.getNivelTanqueInferior(),
                dataManager.getNivelTanqueSuperior(),
                dataManager.getErro(),
                dataManager.getSetpoint(),
                dataManager.getReferencia());
        pnlGraficoTensao.setValues(dataManager.getuSaturado(),
                dataManager.getU(),
                dataManager.getUp(),
                dataManager.getUi(),
                dataManager.getUd());
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        pnlGraficoNivel = new dca.sistemascontrole.view.grafico.GraficoNivel();
        pnlGraficoTensao = new dca.sistemascontrole.view.grafico.GraficoTensao();
        pnlOpcaoGraficosHolder = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        pnlGraficoNivel.setBackground(new java.awt.Color(255, 255, 255));
        pnlGraficoNivel.setBorder(javax.swing.BorderFactory.createTitledBorder("Variáveis de Nivel"));

        pnlGraficoTensao.setBackground(new java.awt.Color(255, 255, 255));
        pnlGraficoTensao.setBorder(javax.swing.BorderFactory.createTitledBorder("Variáveis de Tensão"));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnlGraficoNivel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(pnlGraficoTensao, javax.swing.GroupLayout.DEFAULT_SIZE, 1095, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(pnlGraficoNivel, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)
                .addGap(0, 0, 0)
                .addComponent(pnlGraficoTensao, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE))
        );

        pnlOpcaoGraficosHolder.setBackground(new java.awt.Color(255, 255, 255));
        pnlOpcaoGraficosHolder.setBorder(javax.swing.BorderFactory.createTitledBorder("Opções dos Gráficos"));
        pnlOpcaoGraficosHolder.setLayout(new java.awt.BorderLayout());

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlOpcaoGraficosHolder, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(pnlOpcaoGraficosHolder, javax.swing.GroupLayout.DEFAULT_SIZE, 620, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(0, 0, 0))
        );

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private dca.sistemascontrole.view.grafico.GraficoNivel pnlGraficoNivel;
    private dca.sistemascontrole.view.grafico.GraficoTensao pnlGraficoTensao;
    private javax.swing.JPanel pnlOpcaoGraficosHolder;
    // End of variables declaration//GEN-END:variables
}
